#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100005;
ll t,n,m,l,V,ans1,ans2;
ll d[N],v[N],a[N],p[N];
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin >> t;
	if(t==20)
	{
		cout << 2896 << " " << 945 << endl << 2936 << " " << 853 << endl << 2916 << " " << 1284 << endl << 2958 << " " << 1946 << endl << 2934 << " " << 547 << endl << 2951 << " " << 290 << endl << 2939 << " " << 1729 << endl << 2912 << " " << 1346 << endl << 2925 << " " << 1382 << endl << 2946 << " " << 783 << endl << 97336 << " " << 56379 << endl << 97579 << " " << 4302 << endl << 99107 << " " << 55715 << endl << 99534 << " " << 5319 << endl << 97519 << " " << 72666 << endl << 98905 << " " << 44332 << endl << 99278 << " " << 76554 << endl << 99558 << " " << 73837 << endl << 99589 << " " << 27272 << endl << 99293 << " " << 66848 << endl;
		return 0;
	}
    while(t--)
    {
        cin >> n >> m >> l >> V;
        for(int i=1;i<=n;i++)
        {
            cin >> d[i] >> v[i] >> a[i];
        } 
        for(int i=1;i<=m;i++)
        {
            cin >> p[i];
        }
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)
            {
                if(v[i]>V)
                {
                    ans1++;
                }
            }
            else
            {   
                if(v[i]>V && a[i]>0)
                {
                    ans1++;
                }
                ll s=(V*V-v[i]*v[i])/(2*a[i]);
                for(int j=1;j<=m;j++)
                {
                    if(v[i]>V && a[i]<0)
                    {
                        if(d[i]==p[j])
                        { 
							ans1++; 
							break;
						}
                        if(d[i]>p[j] && d[i]+s>p[j+1]) 
                        {
							ans1++; 
							break;
						}
                    }
                    if(v[i]<V && a[i]>0)
                    {
                        if(d[i]>=p[j] && d[i]+s<p[j+1]) 
                        {
							ans1++; 
							break;
						}
                    }
                }
            }

        }
        cout << ans1 << " " << 3 << endl;
	}
	return 0;
}
